
#pragma once
#include <string>
#include <memory>
#include "core/toxencrypt.h"
#include "audio/include/audio/iaudiocontrol.h"

class Settings;
class Core;
class CoreAV;
class BootstrapNodeUpdater;


class ToxDeskApp {

public:
    void start();
    void setSettings(Settings* settings);
    static ToxDeskApp& getInstance();
    static void destroyInstance();
    static Core* getCore();
public:
     void loadProfile(const std::string& toxdatapath, const std::string& password);
     void loadbootstrapNodes(const std::string& nodepath);
    std::string setPassword(const std::string& newPassword);
    void onSaveToxSave();
    std::string& getSimpleId();
    std::string getToxKeyFromSimpleId(std::string& id);
private:
    bool saveToxSave(std::vector<unsigned char> data);
    void initCore(const std::vector<unsigned char>& toxsave, bool isNewProfile);
    void regSimpleId();
     std::unique_ptr<ToxEncrypt> loadToxData(const std::string& password, const std::string& filePath,std::vector<unsigned char>& data);
private:
    explicit ToxDeskApp();

    ~ToxDeskApp();
private:
    std::unique_ptr<Core> core;
    std::unique_ptr<CoreAV> coreAv;
    std::unique_ptr<ToxEncrypt> passkey;
    bool encrypted = false;
    std::unique_ptr<BootstrapNodeUpdater> bootstrapNodes;
    std::string toxDataPaths;
    Settings* settings;
    std::string simpleId;
    std::unique_ptr<IAudioControl> audioControl;
};
